
import 'package:flutter/material.dart';
import 'package:flutter_hotwork/Myapplication.dart';
import 'package:flutter_hotwork/bean/hotuserinfobean.dart';
import 'package:flutter_hotwork/homepage/BaseTitleBar.dart';
import 'package:flutter_hotwork/homepage/BaseViewBar.dart';
import 'package:flutter_hotwork/zhifa/QuestionEdit.dart';
import 'package:flutter_hotwork/zhifa/QuestionListBean.dart';
import 'package:fluttertoast/fluttertoast.dart';

import '../HomePage.dart';
import 'ChangeAct.dart';

class ReYongHuShuJuNewScreen extends StatefulWidget {
  @override
  ReYongHuShuJuState createState() => new ReYongHuShuJuState();

}
class ReYongHuShuJuState extends State<ReYongHuShuJuNewScreen> {
  final textEditingController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    ScrollController controller = ScrollController();
    double rpx = MediaQuery
        .of(context)
        .size
        .height / 800;
    double rpxw = MediaQuery
        .of(context)
        .size
        .width / 750;


    textEditingController.addListener(() {
      print('input:${textEditingController.text}');
      setState(() {

      });
    });

    return Scaffold(
      appBar: new BaseViewBar(
          childView: new BaseTitleBar(
            "热用户数据",
            leftIcon: 'images/fanhui.png',
            rightIcon:  '',
            rightClick: () {
              print("点击了右边干嘛啊。。。哦");

            },
            leftClick: () {
              print("点击了左边干嘛啊。。。哦");
              Navigator.of(context).pop();
            },
          ),
          preferredSize: Size.fromHeight(50.0)),


      body:
      Container(
        child:
        Column(
          children: [
            Container(
              height: 30,
              margin: EdgeInsets.only(left: 10, top: 10, right: 10, bottom: 10),
              width: rpx * 600,
              padding: EdgeInsets.only(left: 10, top: 0, right: 10, bottom: 0),
              decoration: BoxDecoration(
                border: new Border.all(color: Color(0xFF9E9E9E), width: 0.5),
                // 边色与边宽度
                color: Colors.white,
                // 底色
                //        borderRadius: new BorderRadius.circular((20.0)), // 圆角度
                borderRadius: BorderRadius.all(Radius.circular(15)),
              ),
              child:
              Center(child: TextField(
                controller: textEditingController,
                style: TextStyle(color: Colors.grey),
//                            controller: phoneController,
                decoration: InputDecoration(
                  icon: Icon(Icons.search),
                  contentPadding: EdgeInsets.all(8.0),
                  hintText: '搜索用户名',
                  hintStyle: TextStyle(color: Colors.grey),
//                            helperText: '请输入注册的手机号',
                  border: InputBorder.none,
                ),
                autofocus: false,
              ),),
            ),
            Container(
              color: Color.fromARGB(200, 6, 123, 248),
              width: rpxw*730,
              child:
              Center(
                child:
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  mainAxisSize: MainAxisSize.max,
//                交叉轴的布局方式，对于column来说就是水平方向的布局方式
                  crossAxisAlignment: CrossAxisAlignment.center,
                  //就是字child的垂直布局方向，向上还是向下
                  verticalDirection: VerticalDirection.down,
                  children: [
                    Container(
                        height: 30,
                        width: rpxw*180,
                        child:
                        Center(
                          child:
                          Text("用户名",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                    Container(
                        height: 30,
                        width: rpxw*115,
                        child:
                        Center(
                          child:
                          Text("工作压力",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                    Container(
                        height: 30,
                        width: rpxw*115,
                        child:
                        Center(
                          child:
                          Text("工作温度",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                    Container(
                        height: 30,
                        width: rpxw*80,
                        child:
                        Center(
                          child:
                          Text("瞬时流量",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                    Container(
                        height: 30,
                        width: rpxw*150,
                        child:
                        Center(
                          child:
                          Text("余额",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                    Container(
                        height: 30,
                        width: rpxw*50,
                        child:
                        Center(
                          child:
                          Text("数据",
                            style: TextStyle(color: Colors.white, fontSize: 8,),
                          ),
                        )
                    ),
                  ],

                ),
              ),
            ),

            Expanded(
              child:
              genContentList(
                  MyApplication.getUserList(textEditingController.text),context, controller
              ),
            ),
          ],
        ),
      ),
    );
  }
}



genContentList(List<FocusHotUserVos> data, BuildContext context, controller){
  double rpx = MediaQuery.of(context).size.width / 750;
  double rpxw = MediaQuery
      .of(context)
      .size
      .width / 750;
  return ListView.builder(
      shrinkWrap: true,
      controller: controller,
      itemCount: data.length,
      itemBuilder:(BuildContext context, int index){
        return
        Column(children: [
          data[index].type==1?Container(
            height: 15,
            width: rpxw*730,
            color: Color.fromARGB(150, 6, 123, 248),
            child:  Center(
              child:
              Text(data[index].lineName,
                style: TextStyle(color: Colors.white, fontSize: 8,),
              ),
            )
          ):Container(),
          Row(
          mainAxisAlignment: MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.max,
//                交叉轴的布局方式，对于column来说就是水平方向的布局方式
          crossAxisAlignment: CrossAxisAlignment.center,
          //就是字child的垂直布局方向，向上还是向下
          verticalDirection: VerticalDirection.down,
          children: [
            Container(
                height: 30,
                width: rpxw*180,
                child:
                Center(
                  child:
                  Text(data[index].fullName,
                    style: TextStyle(color: Colors.black, fontSize: 8,),
                  ),
                )
            ),
            Container(
                height: 30,
                width: rpxw*115,
                child:
                Center(
                  child:
                  Text(data[index].jobStress.toString(),
                    style: TextStyle(color: Colors.black, fontSize: 8,),
                  ),
                )
            ),
            Container(
                height: 30,
                width: rpxw*115,
                child:
                Center(
                  child:
                  Text(data[index].jobTemperature.toString(),
                    style: TextStyle(color: Colors.black, fontSize: 8,),
                  ),
                )
            ),
            Container(
                height: 30,
                width: rpxw*80,
                child:
                Center(
                  child:
                  Text(data[index].instantFlow.toString(),
                    style: TextStyle(color: Colors.black, fontSize: 8,),
                  ),
                )
            ),
            Container(
                height: 30,
                width: rpxw*150,
                child:
                Center(
                  child:
                  Text(data[index].balance.toString(),
                    style: TextStyle(color: Colors.black, fontSize: 8,),
                  ),
                )
            ),
            Container(
              height: 30,
              width: rpxw*50,
              child:
              Center(
                child:
                Image(
                  height: 15,
                  width: 15,
                  image:AssetImage(data[index].dataStatus==1?"images/lvse.png":"images/hongse.png"),),
              ),
            ),

          ],

        ),
        ],
        );

      }
  );
}
















void _login() {

}